package com.hy.thread;

import com.hy.admin.service.CourseService;
import com.hy.admin.service.MessageService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TranslateFailThread implements Runnable{
    protected final Logger logBase = LoggerFactory.getLogger(TranslateFailThread.class);

    CourseService courseService = (CourseService) SpringContextUtil.getBean("courseServiceImpl");

    private String uuid;

    public TranslateFailThread(String uuid) {
        this.uuid = uuid;
    }

    @Override
    public void run() {
        if(!StringUtils.isEmpty(uuid)){
            try {
                int count = 0;
                while(count <= 0) {
                    //如果插入数据失败，5秒后继续插入直到成功为止
                    Thread.sleep(5000);
                    count = courseService.addTranslateFailLog(uuid);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
